const Mock = require('mockjs')
const count=100;
const AgencyList=[];
for(let i=0;i<count;i++){
    AgencyList.push(Mock.mock({
      id: '@increment',
      contractnumber:'@integer(209011234,579011234)',
      salesnumber:'@integer(409011234,879011234)',
      number:'@integer(409011234,879011234)',
      salesdate:'@datetime',
      customername:'@first',
      customerphone:'@phone',
      'salescar|1': ['宝马', '奥迪', '本田', '日立','特斯拉'],
      vincode:'@integer(311234,821234)',
      salesprice:'@float(0, 100, 2, 2)',
      paytype:'@integer(1,3)',
      fullpaystate:'@integer(0,1)',
      extraaddstate:'@integer(0,2)',
      insurancestate:'@integer(0,2)',
      agencystate:'@integer(0,2)',
      redemptioncert:'@integer(0,1)',
      state:'@integer(0,6)',
      createtime:'@datetime',
    }))
  
  }

const RegisterFeeList=[];
for(let i=0;i<count;i++){
    RegisterFeeList.push(Mock.mock({
      id: '@increment',
      bussiness:'@integer(1,10)',
      totalmoney:'@phone',
      operator:'@first',
      state:'@integer(0,3)',
      createtime:'@datetime',
    }))
  
  }

  const LoanList=[];
  for(let i=0;i<count;i++){
    LoanList.push(Mock.mock({
      id: '@increment',
      contractnumber:'@integer(209011234,579011234)',
      loannumber:'@integer(409011234,879011234)',
      customername:'@first',
      customerphone:'@phone',
      'salescar|1': ['宝马', '奥迪', '本田', '日立','特斯拉'],
      guider:'@first',
      loanyear:'@integer(1,10)',
      loanmoney:'@integer(200000,40000000)',
      loancontract:'@integer(409011234,879011234)',
      'loanbank|1':['招商银行','明生银行','农业银行','工业银行'],
      loanstate:'@integer(0,3)',
      rebatestate:'@integer(0,1)',
      recordrebate:'@integer(0,1)',
      state:'@integer(0,6)',
      createtime:'@datetime',
    }))
  
  }


module.exports=[
    //AgencyList
    {
        url: '/api/agency/agencylist',
        type: 'get',
        response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query
    
          let mockList = AgencyList.filter(item => {
            return true
          })
    
          if (sort === '-id') {
            mockList = mockList.reverse()
          }
    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },

    //agencydetails
    {
        url: '/api/agency/agencydetails',
        type: 'get',
        response: config => {
            var rd=parseInt(Math.random()*count);
            var item= AgencyList[rd];
            return {
                code: '10000',
                data: item
              }
        }
    },

    //registerfeelist
    {
        url: '/api/agency/registerfeelist',
        type: 'get',
        response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query
    
          let mockList = RegisterFeeList.filter(item => {
            return true
          })
    
          if (sort === '-id') {
            mockList = mockList.reverse()
          }
    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    //loanlist
    {
        url: '/api/agency/loanlist',
        type: 'get',
        response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query
    
          let mockList = LoanList.filter(item => {
            return true
          })
    
          if (sort === '-id') {
            mockList = mockList.reverse()
          }
    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
]